//
//  SceneReader.h
//  Moo-O Touch
//
//  Created by Reisen on 8/3/12.
//  Copyright 2012 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>

@interface VideoReader : NSObject
{
    AVAsset* mAsset;
    AVAssetReader* mAssetReader;
    AVAssetReaderTrackOutput* mReaderOutput;
    UIImage* mUIImage;
    CMSampleBufferRef buffer;
    CMSampleBufferRef nextBuffer;
    
    @public
    int msTime;
    int nextMsTime;
    
    AVPlayer* audioPlayer;
    
    AVMutableComposition* composition;
    
    BOOL isInitialized;
   
    CGAffineTransform transform;
}

@property (assign) long duration;
@property(nonatomic, strong) NSString* filePath;

-(void) openVideo:(NSString*)path;
-(void) openVideo:(NSString*)path fromTime:(CMTime)startTime;

-(UIImage*) readVideoAtFrame:(long)frame;
-(CMSampleBufferRef) readVideoSampleAtFrame:(long)frame;
-(void) closeVideo;
-(BOOL) isEOF;

-(void) playAudio;
-(void) playAudioFromTime:(NSTimeInterval)time;
-(void) pauseAudio;
-(void) resumeAudio;
@end
